import Mock from 'mockjs'
import {config} from "@vue/test-utils";

//频道与群组名数组
const titleArray = []
//时间数组
const timeArray = ['@datetime("2019-12-dd HH:mm:ss")', '@datetime("2020-01-dd HH:mm:ss")']
//频道与群组地址数组
const urlArray = [ 'https://t.me/bandwagonhost_pro']
//消息类型数组
const msgTypeArray = ['文本', '语音', '文件', '图片', '视频', '音频']
//消息数组
const msgArray = []
//用户名数组
const usernameArray = ['暂无', '@qiangwei233', '@disinmison', '@hlwlyhccc', '@NZESupB', '@congcong', '@icola', '@xXyzzo', '@CNBlackListRBot', '@m1scew_bot', '@Jahgandia', '@JiaoQiMJR88', '@MissRose_bot']
//昵称数组
const nicknameArray = []
//个人简介数组
const profileArray = [ ]

export default [
  {
    url: '/table/list',
    type: 'get',
    response: config => {
      const pageSize = config.query.pageSize
      const option = {};
      option['items|' + pageSize] = [{
        id: '@id',
        'chatTitle|1': titleArray,
        'chatUrl|1': urlArray,
        'status|1': ['已监听', '未监听', '注销'],
        'type|1': ['群组', '频道'],
        'info|1': ['本群为博牛社区官方交流群社区网址：https://www.boniu.info/博牛便民换汇t.me/huanhuiphp博牛便民租房群t.me/boniuhouse禁止其它一切类型的广告如：外卖 违者踢出群聊', '群组简介'],
        monitorType: '0',
        monitorAccount: '@integer(10,100000)',
        display_time: timeArray[1],
        pageviews: '@integer(300, 5000)',
        isDisplay: 0,

      }];
      console.log(config.query)
      const items = Mock.mock(option).items;
      return {
        totalPage: 15800,
        pageSize: pageSize,
        currentPage: config.query.currentPage,
        data: items,
        msg: "success",
        code: 200
      }
    }
  },
  //敏感用户
  {
    url: '/table/getSensitiveUsers',
    type: 'get',
    response: config => {
      const pageSize = config.query.pageSize
      const option = {};
      option['items|' + pageSize] = [{
        id: '@integer(0, 1999)',
        userId: '@integer(0, 1999)',
        'userName|1': usernameArray,
        'userFirstName|1': nicknameArray,
        'userLastName|1': nicknameArray,
        'profile|1': profileArray,
        'profile_photo': '/fileRoot/1.png',
        'lastOnline|1': '1 week ago',
        'gmtCreate|1': timeArray,
        'gmtModify|1': timeArray
      }];
      const sensitiveUsersItems = Mock.mock(option);
      const items = sensitiveUsersItems.items;
      return {
        totalPage: 15800,
        pageSize: pageSize,
        currentPage: config.query.currentPage,
        data: items,
        msg: 'success',
        code: 200
      }
    }
  },
  //消息检索
  {
    url: '/table/messageSearch',
    type: 'get',
    response: config => {
      const keyword = config.query.keyword
      const username = config.query.username
      const channelGroup = config.query.channelGroup
      const timeRange = config.query.timeRange
      const option = {};
      option['items|18'] = [{
        id: '@integer(0, 1999)',
        'from|1': channelGroup == '' ? titleArray : channelGroup,
        'smsg|1': msgArray,
        'emsg|1': msgArray,
        highlight: keyword,
        'username|1': username == '' ? usernameArray : username,
        'nickname|1': nicknameArray,
        'time|1': timeArray
      }];
      const sensitiveUsersItems = Mock.mock(option);
      const items = sensitiveUsersItems.items;
      return {
        data: items,
        msg: 'success',
        code: 200
      }
    }
  }, {
    url: '/table/getmessageNumber',
    type: 'get',
    response: _ => {
      return {
        code: 200,
        data: {
          pvData: [
            {key: 'SSR交流 ', pv: "300"},
            {key: 'BNZssr慈善组 ', pv: "152"},
            {key: 'Czssr 鸡主联盟🔥(原书生集团)⭐️⭐️', pv: "163"},
            {key: '分享公益ssr节点shadowrocket🚀🚀🚀', pv: "672"}
          ]
        }
      }
    }
  },
  //查看用户最近消息
  {
    url: '/table/getSpoken',
    type: 'get',
    response: config => {
      const pageSize = config.query.pageSize
      const username = config.query.username
      const nickname = config.query.nickname
      const option = {};
      option['items|' + pageSize] = [{
        username: username,
        nickname: nickname,
        messageId: '@integer(0, 1999)',
        'message|1': msgArray,
        'type|1': '文本',
        'sendTime|1': timeArray,
      }];
      const sensitiveUsersItems = Mock.mock(option);
      const items = sensitiveUsersItems.items;
      return {
        totalPage: 20000,
        pageSize: pageSize,
        currentPage: config.query.currentPage,
        data: items,
        msg: 'success',
        code: 200
      }
    }
  },
  //账号管理
  {
    url: '/table/getAccount',
    type: 'get',
    response: config => {
      const pageSize = config.query.pageSize
      const option = {};
      option['items|' + pageSize] = [{
        account: /^1[385][1-9]\d{8}/,
        chatNumber: '@integer(0, 100)',
        loginTime: timeArray[1],
        'platform|1': ['电报', '币用'],
        sendTime: timeArray[1],
      }];
      let sensitiveUsersItems;
      if (config.query.currentPage == 1) {
        sensitiveUsersItems = Mock.mock(option);
      } else {
        sensitiveUsersItems = Mock.mock(option);

      }
      const items = sensitiveUsersItems.items;
      return {
        totalPage: 20000,
        pageSize: pageSize,
        currentPage: config.query.currentPage,
        data: items,
        msg: 'success',
        code: 200
      }
    }
  }
]
